package com.example.android.adsense.tabs;

import android.app.Activity;
import android.app.TabActivity;
import android.os.Bundle;
import android.widget.TabHost;
import com.google.ads.AdSenseSpec;
import com.google.ads.GoogleAdView;

public class AdSenseTabActivity extends TabActivity
{
    private TabHost mTabHost;

    // Replace with your own AdSense client ID.
    private static final String CLIENT_ID = "ca-mb-app-pub-nnnnnnnnnnnnnnnn";

    // Replace with your own company name.
    private static final String COMPANY_NAME = "Company Name";

    // Replace with your own application name.
    private static final String APP_NAME = "App Name";

    // Replace with your own keywords used to target Google ad.
    // Join multiple words in a phrase with '+' and join multiple phrases with ','.
    private static final String KEYWORDS = "hotels+san+francisco";

    // Replace with your own AdSense channel ID.
    private static final String CHANNEL_ID = "6562723305";


    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mTabHost = getTabHost();

        mTabHost.addTab(mTabHost.newTabSpec("tab_test1").setIndicator("TAB 1").setContent(R.id.textview1));
        mTabHost.addTab(mTabHost.newTabSpec("tab_test2").setIndicator("TAB 2").setContent(R.id.textview2));
        mTabHost.addTab(mTabHost.newTabSpec("tab_test3").setIndicator("TAB 3").setContent(R.id.textview3));

        mTabHost.setCurrentTab(0);

        GoogleAdView adView = (GoogleAdView) findViewById(R.id.adview);
        AdSenseSpec adSenseSpec =
            new AdSenseSpec(CLIENT_ID)     // Specify client ID. (Required)
            .setCompanyName(COMPANY_NAME)  // Set company name. (Required)
            .setAppName(APP_NAME)          // Set application name. (Required)
            .setKeywords(KEYWORDS)         // Specify keywords.
            .setChannel(CHANNEL_ID)        // Set channel ID.
            .setAdType(AdSenseSpec.AdType.TEXT)        // Set ad type to Text.
            .setAdTestEnabled(true);       // Keep true while testing.

        // Fetch Google ad.
        // PLEASE DO NOT CLICK ON THE AD UNLESS YOU ARE IN TEST MODE.
        // OTHERWISE, YOUR ACCOUNT MAY BE DISABLED.
        adView.showAds(adSenseSpec);

    }

}
